import {Text, View} from '@tarojs/components';
import Taro from '@tarojs/taro';
import React, {Component} from 'react';

import * as T from '../types';
import '../css/pay-con.less';
import '../css/index.less';
import actions from '../actions/index';
import {connect} from 'react-redux';
import {store2Props} from '../selectors';

type IPayConProps = T.IProps & T.IPayConProps;

@connect<Partial<IPayConProps>, T.IPayConState>(store2Props, actions)
export default class PayCon extends Component<Partial<IPayConProps>, T.IPayConState> {
  constructor(props: IPayConProps) {
    super(props);
  }

  render() {
    let {
      actions: {action},
      main,
    } = this.props;

    const payIndex = main?.payWay.findIndex((f) => f.id == main?.localData.deliverType);
    return (
      <View className="payCon">
        <View className="order-store-item">
          <Text className="order-item-label">支付/配送</Text>
          <View className="store-item-right">
            <Text className="item-text">
              {main?.localData.deliverType >= 0 && main?.payWay[payIndex] && main?.payWay[payIndex].name}/快递配送
            </Text>
          </View>
        </View>
      </View>
    );
  }
}

//create by moon https://github.com/creasy2010/moon
